<template>
  <div class="depart-item">
    <div class="title">{{ data.areaName }}</div>
    <div class="setting" :class="{alone:data.areaType=='D'&&user.type!='0'&&user.areaId!=data.id&&firstItem!=data.id}">
      <Dropdown transfer stop-propagation v-if="allPermissions.settingAdmin">
        <div style="color:#2d8cf0;margin-right:10px">{{$t("newDevices.setting")}}</div>
        <DropdownMenu slot="list">
          <DropdownItem @click.native="emitAction('settingAdmin')">{{$t("newDevices.settingAdmin")}}</DropdownItem>
        </DropdownMenu>
      </Dropdown>
    </div>
    <div class="setting" v-show="user.type=='0'||user.areaId==data.id||data.areaType=='G'||firstItem==data.id">
      <Dropdown transfer stop-propagation v-if="allPermissions.creatSite||allPermissions.staffDepartmentAddChildEdit||allPermissions.staffDepartmentAddChildDel">
        <Icon type="md-settings" />
        <DropdownMenu slot="list">
          <DropdownItem @click.native="emitAction('create')" v-if="allPermissions.creatSite">{{ $t("newDevices.creatSite1") }}</DropdownItem>
          <DropdownItem @click.native="emitAction('update')" v-if="allPermissions.staffDepartmentAddChildEdit">{{ $t("staffIndex.staffDepartmentAddChildEdit") }}</DropdownItem>
          <DropdownItem v-show="data.parentId!='0'" @click.native="emitAction('del')" v-if="allPermissions.staffDepartmentAddChildDel">{{ $t("staffIndex.staffDepartmentAddChildDel") }}</DropdownItem>
        </DropdownMenu>
      </Dropdown>
    </div>
    <!-- <div class="setting" v-show="data.areaType=='G'&&user.username!='superman'&&user.areaId!=data.id">
      <Dropdown transfer stop-propagation v-if="allPermissions.creatSite||allPermissions.staffDepartmentAddChildEdit||allPermissions.staffDepartmentAddChildDel">
        <Icon type="md-settings" />
        <DropdownMenu slot="list">
          <DropdownItem @click.native="emitAction('create')" v-if="allPermissions.creatSite">{{ $t("newDevices.creatSite1") }}</DropdownItem>
          <DropdownItem @click.native="emitAction('update')" v-if="allPermissions.staffDepartmentAddChildEdit">{{ $t("staffIndex.staffDepartmentAddChildEdit") }}</DropdownItem>
          <DropdownItem @click.native="emitAction('del')" v-if="allPermissions.staffDepartmentAddChildDel">{{ $t("staffIndex.staffDepartmentAddChildDel") }}</DropdownItem>
        </DropdownMenu>
      </Dropdown>
    </div> -->
  </div>
</template>

<script>
export default {
  props: {
    firstItem:Number,
    data: Object,
    // data:JSON.parse(window.sessionStorage.getItem('editItem'))||'',
    allPermissions: Object,
  },
  data () {
    return {
      user:JSON.parse(window.localStorage.getItem('user'))||''
    }
  },
  // created () {
  //   console.log('chanlai',this.data)
  // },
  methods: {
    emitAction (name) {
      this.$emit('action', name)
    },
  },
}
</script>

<style lang="less" scoped>
.depart-item {
  display: flex;
  line-height: 28px;

  .title {
    flex: 1;
    .wrap();
  }
  .setting {
    flex-shrink: 0;
    &.alone{
      margin-right: 14px;
    }
  }
}
</style>
